package com.woniuxy.hrp.web;


import com.woniuxy.hrp.entity.Patient;
import com.woniuxy.hrp.service.PatientService;
import com.woniuxy.hrp.unityhandler.ResponseEntity;
import com.woniuxy.hrp.utils.UUIDUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @program: hrph
 * @InterfaceName PatientLoginController
 * @description: 患者登录
 * @author: shanshanfan
 * @create: 2022-08-30 15:38
 * @Version 1.0
 **/
@CrossOrigin
@Transactional
@RestController
@RequestMapping("/api/v1/patient")
@Slf4j
public class PatientLoginController {

    @Autowired
    private PatientService patientService;

//    @Autowired
//    private JwtUtil jwtUtil;

    @Autowired(required = false)
    //servlet是服务器创建的，所以不属于IOC管理，没法自动注入。sevlet至少也需要服务器启动时，才会创建，而在编写代码时，肯定是不存在滴。
    //该注解不进行检查，服务器启动之后会实例化servlet，这样就不会报错了
    private HttpServletResponse response;



    /**
     * 患者登录
     * @param patient
     * @Author: shanshanfan
     * @return
     */
//    @RequestMapping("/login")
//    public ResponseEntity login(@RequestBody Patient patient) {
//        Patient p = patientService.loginPatient(patient);
//        //查询后为空，账号或密码有错,或者状态未激活/被注销
//        if(p == null) {
//            return ResponseEntity.LOGINFAIL;
//        } else {
//            //还需要认证，取JWT 以及校验JWT
////            String jwt = jwtUtil.createJWT(p.getId(),p.getAccount());
////            log.debug("jwt:{}",jwt);
////
////            //加到响应头header
////            response.addHeader("jwt", jwt);
//            return ResponseEntity.SUCCESS;
//        }
//
//    }


}
